#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef pair<int, int> PII;

PII get_rc(int w, int m)
{
    int m_row = (m - 1) / w;
    int m_col = m - m_row * w;
    if (m_row % 2)
        m_col = w - m_col + 1;
    return {m_row, m_col};
}

int main()
{
    int w, m, n;
    cin >> w >> m >> n;
    if (m > n)
        swap(m, n);
    PII m_rc = get_rc(w, m);
    PII n_rc = get_rc(w, n);
    int ans = n_rc.first - m_rc.first + abs(n_rc.second - m_rc.second);
    cout << ans << endl;
    return 0;
}